package com.lzh.healthCode.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzh.healthCode.business.entity.UpdParams;
import com.lzh.healthCode.business.entity.ZyInfoBean;
import com.lzh.healthCode.business.mapper.ZyInfoMapper;
import com.lzh.healthCode.business.service.ZyInfoService;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author suYanLong
 * @date 2022年07月11日 14:19
 */
@Service
public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfoBean> implements ZyInfoService {

    //获取系统当前时间前一个小时的时间
    public String beforOneHourForDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.HOUR_OF_DAY, -1);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(calendar.getTime());
    }

    //    //获取系统当前时间
    public String nowtime(Date date) {
        Date nowtime = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    @Override
    public List<ZyInfoBean> getSelectAll() {
        ZyInfoServiceImpl zyInfoServiceImpl = new ZyInfoServiceImpl();
        String beforonehourtime = zyInfoServiceImpl.beforOneHourForDay(new Date());
        String nowtime = zyInfoServiceImpl.nowtime(new Date());
        return baseMapper.getSelectAll(beforonehourtime, nowtime);
    }

    @Override
    public List<ZyInfoBean> getSelectSupp(String SAMPLENO) {
        return baseMapper.getSelectSupp(SAMPLENO);
    }

    @Override
    public void updateErrorCount(UpdParams updParams) {
        Integer result = baseMapper.updateErrorCount(updParams);
    }

    @Override
    public List<ZyInfoBean> getSelectTime(UpdParams updParams) {
        return baseMapper.getSelectTime(updParams);
    }

}
